package com.chucknorris.android.ui;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.apps.analytics.GoogleAnalyticsTracker;

public abstract class GAActivity extends FragmentActivity {
	private GoogleAnalyticsTracker tracker;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Start the tracker in manual dispatch mode...
		tracker = GoogleAnalyticsTracker.getInstance();
		tracker.startNewSession("UA-28190723-1", this);
	}

	@Override
	protected void onResume() {
		super.onResume();

		// Track a pageview event
		GoogleAnalyticsTracker.getInstance().trackPageView(getClass().getSimpleName());
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();

		// Stop the tracker when it is no longer needed.
		tracker.dispatch();
		tracker.stopSession();
	}

}
